<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<title>js对象的继承（多方法）</title>
	</head>
	<body>
		<script type="text/javascript">
			/* Object.create(Object.prototype) */
			
				var Person = function(name,age){
					this.name = name;
					this.age = age;
				}
				var me = new Person("lin",19);
				//只有函数有prototype属性
				//Person 的 typeof 为 function
				//实例化的 me 的 typeof 为 Object
				var people = function(){
					
				}
				people.prototype = Object.create(Person.prototype);
				console.log("people.prototype方式继承----" + typeof people);// result: fucntion
				people.prototype.age = 19;
				var peo = new people();//对原型进行实例化
				console.log("name----"+peo.age);// result: 19
				
			
			/* 原型链继承 */
				var Animal = function(kind,num){
					this.kind = kind;
					this.num = num;
				}
				var AnimalC = function(color){
					this.color = color;
				}
				console.log(Animal.prototype);
				AnimalC.prototype = new Animal();
				AnimalC.prototype.kind = "dog";
				console.log(AnimalC);
				console.log(typeof AnimalC);
				
				var monkiy = new AnimalC("monkiy",3)
				console.log("monkiy.kind----"+monkiy.kind)// result: undefined
				//如果对AnimalC的原型进行继承时,将父类实例化就可以获得 monkiy.kind
				
				monkiy = new AnimalC("black");				
				console.log(monkiy.color)// result: black
				
				var animal = new Animal();
				console.log("animal.kind----"+animal.kind)// result: undefined
				//即可得出对子类 AnimalC 的 原型 AnimalC.prototype 的 属性 kind 进行赋值
				//也不会对父级 Animal 的 属性 kind 造成影响 
				//继承的目的即可达到
				//同样可以做到对 子类的延申
				
		</script>
	</body>
</html>